package com.interf;

import com.mes.utils.HttpConnectionData;
import com.yy.base.util.SystemProperties;

/**
 * 飞织数据对接方法类
 */
public class FeizhiUtils {
	private static String SERVICE_URL = SystemProperties.getValue("feizhiServicePath");
	/**
	 * 添加飞织文件
	 * @param facId  设备ID
	 * @param name	 RFID
	 * @param url    物料编码，多个使用,隔开
	 */
	public static void sendFile(String facId, String name, String url) throws Exception {
		HttpConnectionData.sendPost(SERVICE_URL + "sendFile",
				"{\"facId:\"" + facId + "\",\"name\":\"" + name + "\",\"url\":\"" + url + "\"}");
	}
	/**
	 * 添加飞织任务
	 * @param facId 	仓库编码
	 * @param codes		订单编码
	 */
	public static void addTasks(String facId, String []codes) throws Exception {
		String files = getFileNames(codes);
		StringBuilder str = new StringBuilder();
		for (String code : codes) {
			str.append(code).append(",");
		}

		HttpConnectionData.sendPost(SERVICE_URL + "addTasks",
				"{\"facId:\"" + facId + "\",\"codes\":\"" + str + "\",\"files\":\"" + files + "\"}");
	}
	/**
	 * 删除飞织任务
	 * @param facId 	仓库编码
	 * @param codes		订单编码
	 */
	public static void deleteTasks(String facId, String []codes) throws Exception {
		String files = getFileNames(codes);
		StringBuilder str = new StringBuilder();
		for (String code : codes) {
			str.append(code).append(",");
		}

		HttpConnectionData.sendPost(SERVICE_URL + "deleteTasks",
				"{\"facId:\"" + facId + "\",\"codes\":\"" + str + "\",\"files\":\"" + files + "\"}");
	}

	/**
	 * 通过传入工单号，获取工单对于的飞织文件名
	 * @param codes
	 * @return
	 */
	private static String getFileNames(String[] codes) {
		return null;
	}
}